# encoding:utf-8

from flask import Flask
import RPi.GPIO
import time

RPi.GPIO.setmode(RPi.GPIO.BCM)

RPi.GPIO.setup(14, RPi.GPIO.OUT)

app = Flask(__name__)

@app.route('/')
def led():
	RPi.GPIO.setmode(RPi.GPIO.BCM)
	RPi.GPIO.setup(14, RPi.GPIO.OUT)
	print 'liubei, how areyou'
	for i in range(10):
		RPi.GPIO.output(14, True)
		time.sleep(0.5)

		RPi.GPIO.output(14, False)
		time.sleep(0.5)

	RPi.GPIO.cleanup()
	return "hi"


@app.route('/on')
def turnOn():
	RPi.GPIO.setmode(RPi.GPIO.BCM)
        RPi.GPIO.setup(14, RPi.GPIO.OUT)
	print 'turning on the light'
	RPi.GPIO.output(14, True)
	time.sleep(5)
	RPi.GPIO.cleanup()
	return 'turn on'
